/**
 * 游戏角色
 * @author liaosh
 * @date 2022-10-19 22:18
 */
public class GameRole {
    /**
     * 生命值
     */
    private int vit;

    /**
     * 攻击力
     */
    private int atk;

    /**
     * 防御力
     */
    private int def;

    /**
     * 显示角色状态
     */
    public void stateDisplay() {
        System.out.println("角色当前状态：");
        System.out.println("生命值：" + vit + "，攻击力：" + atk + "，防御力：" + def);
    }

    /**
     * 获得初始状态
     */
    public void getInitState() {
        vit = atk = def = 100;
    }

    /**
     * 战斗
     */
    public void fight() {
        vit = atk = def = 0;
    }

    /**
     * 保存状态
     * @return
     */
    public RoleStateMemento saveState() {
        return new RoleStateMemento(vit, atk, def);
    }

    public void recoveryState(RoleStateMemento memento) {
        this.vit = memento.getVit();
        this.atk = memento.getAtk();
        this.def = memento.getDef();
    }
}
